package org.jeecg.chase.common.supper.scene;

import org.jeecg.chase.common.base.data.BaseQuery;
import org.jeecg.chase.common.supper.query.ListQueryContainer;
import org.jeecg.chase.common.utils.InvokeSupportUtils;
import org.springframework.beans.factory.config.BeanDefinition;

import java.util.Set;

/**
 * @author leikai
 * @version 1.0
 * @description:
 * @date 2021/07/23/0023 16:14
 */
public class SceneAnnotationUtils {

    /**
     * 处理query的scene和class
     *
     * @param deanDefinitionSet
     * @return void
     * @author leikai
     * @date 2021/07/26/0026 16:46
     */
    public static void processSceneClass(Set<BeanDefinition> deanDefinitionSet) {

        for (BeanDefinition beanDefinition : deanDefinitionSet) {
            String className = beanDefinition.getBeanClassName();
            Class<?> clazz = InvokeSupportUtils.loadClass(className);
            if (BaseQuery.class.isAssignableFrom(clazz)) {
                SceneContainer.processSceneClass(clazz);
            }
        }
    }

    public static void processBaseDataBeanDefinition(Set<BeanDefinition> deanDefinitionSet) {
        for (BeanDefinition beanDefinition : deanDefinitionSet) {

            String className = beanDefinition.getBeanClassName();
            Class<? extends BaseQuery> clazz = (Class<? extends BaseQuery>) InvokeSupportUtils.loadClass(className);
            ListQueryContainer.processQuery(clazz);
        }
    }
}
